var config = require('../../config.js');
var common = require('../utils/common.js');
var loadSingle=require('load_single.js');
var util = require('../utils/util.js');
var wxParse = require('../../wxParse/wxParse.js');
var app = getApp();

var language = {};
var id = null;          //本视频id

var pre_index = 0;//记录上次的索引
var cur_index = 0;//记录当前的索引

var seconds = 0;//秒数//对于音频记录秒数
var video_seconds = 0;//视频秒数

//var username = '';//表示登录后的用户名
var multi_language = [];
//var audioArr = [];//音频对象存放在数组对象中

var animation=null;
var shareanimation=null;
var videoDuration=0;//视频时长，若是不为0或null，那么不需要再次保存
var touchDot = 0;//触摸时的原点
var touchDotY=0;
var time = 0;//  时间记录，用于滑动时且时间小于1s则执行左右滑动
var interval = "";// 记录/清理 时间记录
var tmpFlag = true;// 判断左右华东超出菜单最大值时不再执行滑动事件
var faid = '2';//防止重复点击收藏（若是点击的收藏正确返回，则点击正常，否则点击无效）

var videoCtx=null;
var title="";
const backgroundAudioManager = wx.getBackgroundAudioManager();
Page({
  onReady: function (e) {
    wx.hideLoading();
    wx.setNavigationBarTitle({
      title: config.barTitle
    });
    // 根据不同的手机屏幕调整视频播放窗口的宽高
    wx.getSystemInfo({
      success: (res) => {
        console.log(res);
        this.setData({
          videoW: res.screenWidth,
          videoH: res.screenWidth * 1080 / 1920,
        })
      },
    })
    videoCtx = wx.createVideoContext('myVideo');  //视频对象
    var that=this;
    if (id != null && id != 0) {
        app.getUserName(function (user_name) {
          //是否收藏
          common.findFavorer_p(user_name, id, function (res) {
            if (res.data) {
              that.setData({favid: '1'});
            } else {
              that.setData({favid: '0'});
            }
          });
        });
    } 
    backgroundAudioManager.title = multi_language[0].title;
    backgroundAudioManager.coverImgUrl = that.data.coverUrl;
  },
  /**
   * 页面的初始数据
   */
  data: {
    // 视频默认宽高
    videoW: '375px',
    videoH: '210.9375px',
    isPopping: true,
    id: null,//指代当前页面（视频id）
    url: '',//视频路径
    title: '',//显示标题
    content: '',//展示内容
    language_list: [],//语言加载列表,
    coverUrl: '',//播放音频的时候，覆盖视频
    video_action: '',//视频播放状态
    favid: '-1',//默认为0 表示没有收藏
    video_record: 0, //表示视频文件初始值,
    make_display: 'none',
    externalQuizUrl: '43191',//试题id；

    pre_id:0,//上一天的
    next_id:0,//下一天的

    cur_index:0,//表示当前索引
    show_finish:0,//表示未完成，不显示

    date:'',//日期
    animationData: {},//动画

    autoPlay:false,//是否自动播放,
    showPic:true,//是否显示上一集和下一集和主页
    showCover:true,//默认显示封面,
    day:'',
    videoDuration:'',//表示播放时长
    etest:true,
    videoPic:'../images/play.png',// 音频播放图片切换
  },

  onShow: function () {
     var animation = wx.createAnimation({
      transformOrigin: "0",
      duration: 1000,
      //timingFunction: 'ease',
      timingFunction:'linear'
    })
    this.animation = animation;

    var shareanimation = wx.createAnimation({
      transformOrigin: "0",
      duration: 1000,
      //timingFunction: 'ease',
      timingFunction: 'linear'
    })
    this.shareanimation = shareanimation;
  },

  initMenu: function (multi_language){//初始化菜单栏
    for (var i = 0; i < 2; i++) {
      language = {};
      language.name = "普通话";
      language.seek=0;//默认从0开始播放
      language.class_name = '';
      language.count=0;
      language.display = 'none';
      language.class_cl_name = '../images/laba_stop.gif';//'../images/laba_end.gif';
      multi_language.push(language);

      try {
        backgroundAudioManager.pause();//音频文件暂停
      } catch (e) { }
    }
  }, coverVideoData: function (language,data){//装载首页获取到的数据
    language.title = data.title;
    language.class_name = 'active';
    language.id = data.id;
    language.url = data.url.replace(/(\s*$)/g, "");
    language.content = data.content;
    language.lastSecond = 0;//记录record （判断是否大于0，若是大于0，则使用该记录，否则不操作）
    //language.viewingCount=data.counter.viewingCount;
    language.viewingCount = data.viewingCount;
    title=data.title;
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中···'
    });
    faid='2';
    video_seconds=0;
    var that = this;
    id = options.id;
    var auto=options.auto;
    
    multi_language = [];

    pre_index = 0;//上一次的索引
    cur_index = 0;//当前的索引

    that.setData({
      common_title:options.title,
      id:id,
      fav_id: id,
      startDate:'00:00'
    });
 
    that.initMenu(multi_language);//初始化菜单
    console.log(config.materialDocuments + '/search/findMaterialById?id='+id);
      wx.request({
       url: config.materialDocuments + '/search/findMaterialById',
       //url: config.materials + '/' + id,
        data: { id: id },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          var data = res.data;
          //data.url ='http://zhunei.oss-cn-shanghai.aliyuncs.com/2017/1/5/%E4%B8%BB%E7%9A%84%E6%81%A9%E5%85%B8%E5%A4%9F%E4%BD%A0%E7%94%A8.mp4';
          var externalQuizUrl=data.externalQuizUrl;
          videoDuration = data.lengthInSecond;
          that.setData({
            common_title: data.title,
            common_content: data.content,
            coverUrl: data.coverUrl,
            externalQuizUrl: externalQuizUrl ? externalQuizUrl.substring(externalQuizUrl.lastIndexOf('/') + 1, externalQuizUrl.length):'', 
            date: util.formateDate(data.showTime),
            day: util.getDays(util.formateDate(data.showTime)),
            videoDuration: util.settime(data.lengthInSecond),
            durationDate: util.settime(data.lengthInSecond),
            percent:0
          });

          wxParse.wxParse('html', 'html', data.content, that, 0);
          if (auto){
            that.setData({
              url: data.url.replace(/(\s*$)/g, ""),
              autoPlay: auto ? true : false,
              showCover:false
            });
            videoCtx.play();
          }else{
          }
          that.coverVideoData(multi_language[0],data);//装载视频数据
          that.setData({
            language_list: multi_language
          });
          //获取其他子语言的信息
          that.loadChildrens(id, multi_language);
          //获取上一天和下一天
          loadSingle.get_material(data.showTime, that);
        }
      
    });
    //监听音频播放情况
     this.listenerAudio();
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];  //上一个页面

    prevPage.setData({
      clickId: 0
    });
    this.collection();
  },
  collection:function(){
    var username='';
    //收藏或不收藏
    if (faid != '-1'&&this.data.favid==faid) {
      app.getUserName(function (username) {
        username=username;
        loadSingle.add_rem_favorite(id, username, faid == "1" ? 'add' : 'remove');
      });
    }
    //视频记录信息
    if (video_seconds>0){
      if (username==''||username==null){
        app.getUserName(function (username) {
          common.add_up_record(id, username, video_seconds);
        });
      }else{
        common.add_up_record(id, username, video_seconds);
      }
    }
    
  },
  //时间格式转换
  dateFormate:function(dateTime){
    if(dateTime){
      var  total=parseInt(dateTime);
      var minutes=parseInt(total/60);//分钟
      var cha = total - minutes*60;
      var seconds=parseInt(cha);
      return minutes >= 10 ? minutes : '0' + minutes + ':' + (seconds >= 10 ? seconds : '0' + seconds);
    }
    return '';
  },
  //监听音频文件播放情况
  listenerAudio:function(){
    var that = this;
    //监听时时更新
    backgroundAudioManager.onTimeUpdate(function () {
      var currentTime=backgroundAudioManager.currentTime;
      var duration = backgroundAudioManager.duration;

      if (currentTime != undefined && duration != undefined) {
        currentTime = parseFloat(currentTime).toFixed(2);
        duration = parseFloat(duration).toFixed(2);

        var duration0 = multi_language[1].duration;
        var percent = currentTime / duration*100;
        
        var startDate=that.dateFormate(currentTime);
        var durationDate=that.dateFormate(duration);

        that.setData({
          starttime: currentTime,
          duration: duration,
          percent: percent,
          startDate: startDate,
          durationDate: durationDate
        });
        multi_language[1].seek = currentTime;
        if (duration0 == undefined || duration0==0){
          multi_language[1].duration = duration;
        }
      }
    });
    //监听音频播放结束
    backgroundAudioManager.onEnded(function(){
      multi_language[1].class_cl_name = '../images/laba_stop.gif';
      that.setData({
        starttime: multi_language[1].duration,
        duration: multi_language[1].duration,
        language_list: multi_language,
        videoPic: '../images/play.png'
      });
      //播放结束的时候，重新将当前的数据，设置
      backgroundAudioManager.title = multi_language[1].title;
      backgroundAudioManager.coverImgUrl = that.data.coverUrl;
      //设置从那个点位开始播放
      backgroundAudioManager.startTime = 0;
      //播放结束，打开播放器
      that.animation.height(30).opacity(1).step();
      that.setData({
        show_finish: 1,//表示播放完成，可以进行上一页或下一页
        animationData: that.animation.export(),
        isPlayFlag:false,
        sharean: "break",
      });
      setTimeout(function () {
        that.setData({
          share:"break"
        });
      },1000); 

      that.shareanimation.translate(10, 5).step()
      that.shareanimation.translate(10, -5).step()
      that.shareanimation.translate(10, 5).step()
      that.shareanimation.translate(10, -5).step()
      that.shareanimation.translate(10, 5).step()
      that.shareanimation.translate(10, -5).step()
      that.setData({
        shareanimation: that.shareanimation.export()
      })

      setTimeout(function () {
        that.shareanimation.translate(20, -5).step()
        that.shareanimation.translate(20, 5).step()
        that.shareanimation.translate(20, -5).step()
        that.shareanimation.translate(20, 5).step()
        that.shareanimation.translate(20, -5).step()
        that.setData({
          shareanimation: that.shareanimation.export()
        })

        setTimeout(function () {
          that.setData({
            sharean: "none"
          })
        }, 5000);
      }, 0)


    });
    //监听音频播放暂停
    backgroundAudioManager.onPause(function(){
      multi_language[1].class_cl_name ='../images/laba_stop.gif';
      that.setData({
        language_list: multi_language,
        videoPic: '../images/play.png'
      });
    });
    //监听播放事件
    backgroundAudioManager.onPlay(function(){
      multi_language[1].class_cl_name = '../images/laba_star.gif';
      that.setData({
        language_list: multi_language,
        videoPic: '../images/pause.png'
      });

      if (that.data.show_finish == 1){
        //表示播放的时候，弹框关闭
        that.animation.height(0).opacity(0).step();
        that.setData({
          show_finish: 0,
          animationData: that.animation.export()
        });

        that.setData({
          share: "none"
        });
      }  
    });
    
  }, //点击音频的播放或暂停按钮的时候
  videoPlayOrPause:function(e){
    var that=this;
    //设置音频播放路径，标题，封面图片
    try{
      videoCtx.pause();
    }catch(e){}
    if (that.data.isPlayFlag == undefined || !that.data.isPlayFlag){
      backgroundAudioManager.src = multi_language[1].url;
      backgroundAudioManager.title  = multi_language[1].title;
      backgroundAudioManager.coverImgUrl = that.data.coverUrl;
      that.setData({
        isPlayFlag:true
      });
    }
    //显示内容
    wx.getBackgroundAudioPlayerState({
      success: function (res) {
        var status = res.status;
        // 播放状态（2：没有音乐在播放，1：播放中，0：暂停中）
        if(status=="0"||status=="2"){//暂停中
          backgroundAudioManager.play();//播放后，样式改变
          that.setData({
            videoPic: '../images/pause.png'
          });
        }else{//播放中
          backgroundAudioManager.pause();//暂停后，样式改变
          that.setData({
            videoPic: '../images/play.png'
          });
        }
      },fail:function(res){
        //接口调用失败
      }
    })

  },
  sliderchange: function (e) {//滑动块改变的时候
    var that=this;
    var offset = parseInt(e.detail.value);
    var duration = multi_language[1].duration;
    if(duration){
      this.setData({
        percent: offset / duration*100
      });
    }
    backgroundAudioManager.seek(offset);  
  },
  favor: function (e) {//收藏或取消
    var that = this;
    var fid = e.currentTarget.dataset.fid;//是否收藏1 是，0 否
    if(id==0||id==null){
      return;
    }
    if (fid == '1') {//表示取消收藏   
        faid = '0';
        that.setData({
          favid: '0'
        });
    } else if (fid == '0') {//表示需要收藏
        faid = '1';
        that.setData({
          favid: '1'
        });
      } 
  },

   video_pro: function (e) {////时时更新视频文件的播放时长
    video_seconds = e.detail.currentTime;
  }, video_pause: function (e) {//视频文件暂停
    //if (video_seconds > 0) {
      //限制在很短时间内防止重复执行
      //app.getUserName(function (user_name) {
      //  common.add_up_record(id, user_name, video_seconds);
      //});
   // }
  },videoPlay:function(e){//第一次：使用封面点击播放按钮
    var that = this;
    that.setData({
      url: multi_language[0].url.replace(/(\s*$)/g, ""),
      showCover: false,
      autoPlay:true
    });
    multi_language[0].class_name = 'active';
    multi_language[0].display = "block";
   
    that.setData({
      language_list: multi_language
    });
    videoCtx.play();
    
  },video_play: function (e) {//视频文件播放的时候，其他页面要暂停播放
    var that = this;
    try{
      backgroundAudioManager.pause();//音频文件暂停
    } catch (e) {}
    this.animation.height(0).opacity(0).step();
    that.setData({
      animationData: this.animation.export(),
      show_finish: 0,
      url: multi_language[0].url.replace(/(\s*$)/g, ""),
      showCover:false
    });

    that.setData({
      share: "none"
    });
    
    if (cur_index==0 ){
      return;
    }
    pre_index = cur_index;//记录上一个视频
    cur_index=0;

    // 调整样式
    var language = multi_language[0];
    for (var i = 1; i < multi_language.length; i++) {
      multi_language[i].class_name = ''
      multi_language[i].display = "none";
      multi_language[i].class_cl_name ='../images/laba_stop.gif';// '../images/laba_end.gif';
    }
    that.setData({
      language_list: multi_language,
      common_title: language.title,
      common_content: language.content,
      cur_index:cur_index
    });

    wxParse.wxParse('html', 'html', multi_language[0].content, that, 0);  
  },
  video_endedHandle: function (e) {//视频文件播放结束
    var that=this;
    console.log(videoDuration + ':' + video_seconds);
    if ((videoDuration == 0 || videoDuration == null || videoDuration == undefined) && video_seconds != undefined && video_seconds > 0) {
      wx.request({
        url: config.materials + '/' + id + '/length',
        data: {
          lengthInSecond: video_seconds
        }, header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          videoDuration = video_seconds;
        }
      })
    }

    this.animation.height(30).opacity(1).step()
    that.setData({
      show_finish: 1,//表示播放完成，可以进行上一页或下一页
      animationData: this.animation.export(),
      sharean: "break",
    })
    setTimeout(function () {
      that.setData({
        share: "break"
      });
    },1000);
    app.getUserName(function (user_name) {
      common.add_up_record(id, user_name, 0);
    });

    that.shareanimation.translate(10, 5).step()
    that.shareanimation.translate(10, -5).step()
    that.shareanimation.translate(10, 5).step()
    that.shareanimation.translate(10, -5).step()
    that.shareanimation.translate(10, 5).step()
    that.shareanimation.translate(10, -5).step()
    that.setData({
      shareanimation: that.shareanimation.export()
    })

    setTimeout(function () {
      that.shareanimation.translate(20, -5).step()
      that.shareanimation.translate(20, 5).step()
      that.shareanimation.translate(20, -5).step()
      that.shareanimation.translate(20, 5).step()
      that.shareanimation.translate(20, -5).step()
      that.setData({
        shareanimation: that.shareanimation.export()
      })

      setTimeout(function () {
        that.setData({
          sharean: "none"
        })
      }, 5000);
    }, 0)

  }, 
  //点击弹出  
  plus: function () {
    if (this.data.isPopping) {
      //缩回动画  
      this.popp();
      this.setData({
        isPopping: false
      })
    } else if (!this.data.isPopping) {
      //弹出动画  
      this.takeback();
      this.setData({
        isPopping: true
      })
    }
  },
  input: function () {
  },
  transpond: function () {
  },
  collect: function () {
  },
  share: function () {
  },
  //弹出动画  
  popp: function () {
    //plus顺时针旋转  
    var animationPlus = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationcollect = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationTranspond = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationInput = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationshare = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    animationPlus.rotateZ(180).step();
    animationcollect.translate(46, 2).rotateZ(0).opacity(1).step();
    animationTranspond.translate(6, 25).rotateZ(0).opacity(1).step();
    animationInput.translate(-15, 67).rotateZ(0).opacity(1).step();
    animationshare.translate(-18, 60).rotateZ(0).opacity(1).step();
    this.setData({
      animPlus: animationPlus.export(),
      animCollect: animationcollect.export(),
      animTranspond: animationTranspond.export(),
      animInput: animationInput.export(),
      animShare: animationshare.export(),
    })
  },
  //收回动画  
  takeback: function () {
    //plus逆时针旋转  
    var animationPlus = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationcollect = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationTranspond = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationInput = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationshare = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    animationPlus.rotateZ(0).step();
    animationcollect.translate(50, 50).rotateZ(180).opacity(0).step();
    animationTranspond.translate(50, 50).rotateZ(180).opacity(0).step();
    animationInput.translate(50, 50).rotateZ(180).opacity(0).step();
    animationshare.translate(50, 50).rotateZ(180).opacity(0).step();
    this.setData({
      animPlus: animationPlus.export(),
      animCollect: animationcollect.export(),
      animTranspond: animationTranspond.export(),
      animInput: animationInput.export(),
      animShare: animationshare.export(),
    })
  },/**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
     // title: config.palyTitle,
      title: title,
      path: '/pages/video/video?&id=' + id,
      imageUrl: '../images/sharepic.jpg'
    }

  }, play: function (e) {
    wx.reLaunch({
       url: '../index/index',
     })
  }, search: function (e) {
    wx.reLaunch({
      url: '../waterfall/waterfall',
    })
  }, user: function (e) {
    wx.reLaunch({
      url: '../user/user',
    })
  },
  preAndnext0: function (e) {//上一集或下一集
    var idd = e.currentTarget.dataset.id;
    this.preAndnext(idd);
  },
  preAndnext:function (idd) {//上一集或下一集
     var that=this;
     var curTime = new Date().getTime();
     //上一次加载的时间
     var lastTime = this.data.lastLoadTime;
     that.setData({
       lastLoadTime: curTime
     });
     if (curTime - lastTime < 2000) {
       wx.showToast({
         title: '换页过于频繁···',
         icon: 'loading',
         duration: 1000
       });
       return;
     }
   
    if(idd==0||idd==null){
      wx.showToast({
        title: '暂无更新···',
        icon: 'loading',
        duration: 1000
      });
      return;
    }
    var recordId=id;
    id=idd;
    wx.showLoading({
      title: '加载中···'
    });
    try{
      videoCtx.pause();
    }catch(e){}

    multi_language = [];
    pre_index = 0;//上一次的索引
    cur_index = 0;//当前的索引

    this.animation.height(0).opacity(0).step();
    var favid1=that.data.favid;
    that.setData({
      animationData: this.animation.export(),
      show_finish:0,
      favid:'-1',
      cur_index:0,
      isPlayFlag: false
    })

    that.setData({
      share: "none"
    });
    var faid1=faid;
    faid='2';//防止重复点击收藏（若是点击的收藏正确返回，则点击正常，否则点击无效）
 
      that.initMenu(multi_language);//初始化菜单
      wx.request({
        url: config.materials + '/' + id,
        data: {
        },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          var data = res.data;
          var externalQuizUrl = data.externalQuizUrl;
          videoDuration = data.lengthInSecond;
          that.setData({
            fav_id: data.id,
            id: data.id,
            common_title: data.title,
            common_content: data.content,
            coverUrl: data.coverUrl,
            externalQuizUrl: externalQuizUrl?externalQuizUrl.substring(externalQuizUrl.lastIndexOf('/') + 1, externalQuizUrl.length):'', 
            date: util.formateDate(data.showTime),
            autoPlay: '',
            showCover:true,
            day: util.getDays(util.formateDate(data.showTime)),
            videoDuration: util.settime(data.lengthInSecond),
            durationDate: util.settime(data.lengthInSecond),
            percent:0
          });

          wxParse.wxParse('html', 'html', data.content, that, 0);
          
          that.coverVideoData(multi_language[0], data);//装载视频数据
          that.setData({
            language_list: multi_language
          });
         
          //获取其他子语言的信息
          that.loadChildrens(id, multi_language);
         
          loadSingle.get_material(data.showTime, that);
          wx.hideLoading();

          app.getUserName(function (user_name) {
            if (faid1 != '-1' && favid1 == faid1) {
              loadSingle.add_rem_favorite(recordId, user_name, faid1 == "1" ? 'add' : 'remove');
            }
            if (video_seconds>0){
              common.add_up_record(recordId, user_name, video_seconds);
            }
            video_seconds=0;
            //是否收藏
            common.findFavorer_p(user_name, id, function (res) {
              if (res.data) {
                that.setData({ favid: '1' });
              } else {
                that.setData({ favid: '0' });
              }
            });
          });
        }
      });
  },
  
  // 触摸开始事件
    touchStart: function(e) {
      touchDot = e.touches[0].pageX; // 获取触摸时的原点
      touchDotY = e.touches[0].pageY; // 获取触摸时的原点
      // 使用js计时器记录时间    
      interval = setInterval(function () {
        time++;
      }, 100);
    },
  // 触摸移动事件
  touchMove: function (e) {
    var that=this;
    var touchMove = e.touches[0].pageX;
    var touchMoveY = e.touches[0].pageY;
    
    // 向左滑动   
    if (touchMove - touchDot <= -40 && touchDotY - touchMoveY < 8 && touchDotY - touchMoveY >= 0) {
      if (tmpFlag) { //每次移动中且滑动时不超过最大值 只执行一次 ++
        tmpFlag = false;
        this.preAndnext(this.data.next_id);
      }
    }

    // 向右滑动
    if (touchMove - touchDot >= 40 && touchDotY - touchMoveY < 8 && touchDotY - touchMoveY >=0) {
      if (tmpFlag) {
        tmpFlag = false;
        this.preAndnext(this.data.pre_id);
      }
    }
  },
  // 触摸结束事件
  touchEnd: function (e) {
    clearInterval(interval); // 清除setInterval
    time = 0;
    tmpFlag = true; // 回复滑动事件
  },  //获取其他子语言的信息
  loadChildrens: function (id, multi_language){
    var that=this;
    wx.request({
      url: config.materials + '/' + id + '/childMaterials',
      data: {
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        var data = res.data;
        var materials = data._embedded.materials;

        var index = 1;
        for (var i = 0; i < materials.length; i++) {
          var name = '';
          if (materials[i].dialect =="MANDARIN"){
            index = 1;
            language = multi_language[index];
            language.title = materials[i].title;
            language.class_name = '';
            language.id = materials[i].id;
            language.url = materials[i].url;
            language.content = materials[i].content;
            language.count = 0;
          }
        }
        that.setData({
          language_list: multi_language
        });
        
      }
    });
  }
}) 

